//
//  NetWorkRequest.h
//  OCDemo
//
//  Created by zhumuzhi on 2021/3/18.
//

#import "AFNetworking.h"
#import "OCNetworkDefine.h"
#import "RequestInfoModel.h"
#import "RequestParams.h"

#pragma mark - 成功失败block
///**
// *  请求成功时的回调
// *
// *  @param returnData        请求成功数据集合
// *  @param requestInfoModel  XFSRequestInfoModel
// */
//typedef void (^NetworkRequestSuccessBlock)(id _Nullable returnData,RequestInfoModel * _Nullable requestInfoModel);
//
///**
// *  请求错误的回调
// *
// *  @param error             请求失败error集合
// *  @param requestInfoModel  XFSRequestInfoModel
// */
//typedef void (^NetworkRequestFailureBlock)(NSError * _Nullable error,RequestInfoModel * _Nullable requestInfoModel);

/**
 *  上传下载进度block
 *
 @param progress NSProgress对象
 */
typedef  void (^ProgressBlock)(NSProgress * _Nullable progress);


NS_ASSUME_NONNULL_BEGIN

@interface NetWorkRequest : NSObject


/// 单例方法
+ (instancetype)sharedNetworkRequest;


#pragma mark - Get请求

- (NSURLSessionDataTask *)getRequest:(NSString *)url
                          parameters:(NSDictionary *)parameter
                        successBlock:(NetworkRequestSuccessBlock)successBlock
                        failureBlock:(NetworkRequestFailureBlock)failureBlock;

#pragma mark - Post请求 参数

- (NSURLSessionDataTask *)postRequest:(NSString *)url
                           parameters:(NSDictionary *)parameter
                         successBlock:(NetworkRequestSuccessBlock)successBlock
                         failureBlock:(NetworkRequestFailureBlock)failureBlock;
#pragma mark - Post请求 Body

- (NSURLSessionDataTask *)postBodyRequest:(NSString *)url
                               parameters:(NSDictionary *)parameter
                             successBlock:(NetworkRequestSuccessBlock)successBlock
                             failureBlock:(NetworkRequestFailureBlock)failureBlock;


#pragma mark - UploadFile请求 文件
- (NSURLSessionDataTask *)uploadFileWithUrl:(NSString *)url
                                 parameters:(NSDictionary *)parameter
                                  fileNames:(NSArray *)fileNames
                                      files:(NSArray *)files
                               successBlock:(NetworkRequestSuccessBlock)successBlock
                               failureBlock:(NetworkRequestFailureBlock)failureBlock;

#pragma mark - UploadFile请求 压缩文件
- (NSURLSessionDataTask *)uploadImageZipWithUrl:(NSString *)url
                                     parameters:(NSDictionary *)parameter
                                       progress:(ProgressBlock)uploadProgress
                                  imagesZipPath:(NSURL *)imagesZipPath
                                   successBlock:(NetworkRequestSuccessBlock)successBlock
                                   failureBlock:(NetworkRequestFailureBlock)failureBlock;

#pragma mark - UploadFile请求 视频文件
- (NSURLSessionDataTask *)uploadVideoWithUrl:(NSString *)url
                                  parameters:(NSDictionary *)parameter
                                   videoPath:(NSURL *)videoPath
                                successBlock:(NetworkRequestSuccessBlock)successBlock
                                failureBlock:(NetworkRequestFailureBlock)failureBlock;

#pragma mark - downloadFile请求
- (NSURLSessionDownloadTask *)downloadFileWithUrl:(NSString *)strUrl
                                    localSavePath:(NSString *)savePath
                                         progress:(ProgressBlock)progressBlock
                                     successBlock:(NetworkRequestSuccessBlock)successBlock
                                     failureBlock:(NetworkRequestFailureBlock)failureBlock;



#pragma mark - Private Method
#pragma mark - 取消网络请求（全部 或者 单个）
- (void)cancelNetworkRequest ;

//取消单个网络请求
- (void)cancelNetworkRequestWithTask:(NSURLSessionTask *)task ;

@end

NS_ASSUME_NONNULL_END
